<template>
  <bar-chart id="instCatStats" title="实例分类统计" :data-source="instStatsDs" type="Bar" />
</template>

<script>
import BarChart from '@neu/biz-core/components/Charts/BarChart'
import { statsByCategory as instanceStatsByCategory } from '@neu/cmdb-ui/api/instance'
export default {
  name: 'InstCatStats',
  components: {
    BarChart
  },
  data() {
    return {
      instStatsDs: []
    }
  },
  created() {
    instanceStatsByCategory().then(response => {
      this.instStatsDs = response.data.map(it => [it.name, it.count])
    })
  }
}
</script>
